package zhtt.example.filter2;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class MyPreFilter implements GatewayFilter {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        exchange.getRequest().mutate()
                .header("token0", "MyPreFilter")
                .build();
        // 在此处编写前置过滤器的逻辑
        System.out.println("在此处编写前置过滤器的逻辑");
        return chain.filter(exchange);
    }
}
